﻿//-------------------------------------------------------------------------------------------
// <copyright file="OfferViewModel.cs" company="Russell Wilkins">
//     Copyright (c) Russell Wilkins 2014. All Rights Reserved.
// </copyright>
// <author>Russell Wilkins</author>
// <license href="license.txt">
//     The use of this software is governed by the Microsoft Public License
//     which is included with this distribution.
// </license>
//-------------------------------------------------------------------------------------------
namespace Ripple.TestClient.ViewModels
{
    using Ripple.Data;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;

    /// <summary>
    /// TODO: Describe the class
    /// </summary>
    public class OfferViewModel : ViewModel<Offer>
    {
        public static readonly DependencyProperty GetsCurrencyProperty = DependencyProperty.Register("GetsCurrency", typeof(string), typeof(OfferViewModel), new PropertyMetadata(string.Empty));
        public static readonly DependencyProperty GetsIssuerProperty = DependencyProperty.Register("GetsIssuer", typeof(string), typeof(OfferViewModel), new PropertyMetadata(string.Empty));
        public static readonly DependencyProperty GetsValueProperty = DependencyProperty.Register("GetsValue", typeof(double), typeof(OfferViewModel), new PropertyMetadata((double)0));
        public static readonly DependencyProperty PaysCurrencyProperty = DependencyProperty.Register("PaysCurrency", typeof(string), typeof(OfferViewModel), new PropertyMetadata(string.Empty));
        public static readonly DependencyProperty PaysIssuerProperty = DependencyProperty.Register("PaysIssuer", typeof(string), typeof(OfferViewModel), new PropertyMetadata(string.Empty));
        public static readonly DependencyProperty PaysValueProperty = DependencyProperty.Register("PaysValue", typeof(double), typeof(OfferViewModel), new PropertyMetadata((double)0));
        public static readonly DependencyProperty SequenceProperty = DependencyProperty.Register("Sequence", typeof(uint), typeof(OfferViewModel), new PropertyMetadata((uint)0));

        /// <summary>
        /// Initializes a new instance of the OfferViewModel class.
        /// </summary>
        public OfferViewModel(Offer offer)
        {
            this.Model = offer;
        }

        public string GetsCurrency
        {
            get { return (string)GetValue(GetsCurrencyProperty); }
            set { SetValue(GetsCurrencyProperty, value); }
        }

        public string GetsIssuer
        {
            get { return (string)GetValue(GetsIssuerProperty); }
            set { SetValue(GetsIssuerProperty, value); }
        }

        public double GetsValue
        {
            get { return (double)GetValue(GetsValueProperty); }
            set { SetValue(GetsValueProperty, value); }
        }

        public string PaysCurrency
        {
            get { return (string)GetValue(PaysCurrencyProperty); }
            set { SetValue(PaysCurrencyProperty, value); }
        }

        public string PaysIssuer
        {
            get { return (string)GetValue(PaysIssuerProperty); }
            set { SetValue(PaysIssuerProperty, value); }
        }

        public double PaysValue
        {
            get { return (double)GetValue(PaysValueProperty); }
            set { SetValue(PaysValueProperty, value); }
        }

        public uint Sequence
        {
            get { return (uint)GetValue(SequenceProperty); }
            set { SetValue(SequenceProperty, value); }
        }

        protected override void RefreshData()
        {
            this.GetsCurrency = this.Model.Gets.Currency;
            this.GetsIssuer = this.Model.Gets.Issuer;
            this.GetsValue = this.Model.Gets.Value;
            this.PaysCurrency = this.Model.Pays.Currency;
            this.PaysIssuer = this.Model.Pays.Issuer;
            this.PaysValue = this.Model.Pays.Value;
            this.Sequence = this.Model.Sequence;
        }
    }
}